using System;
using System.Data;
using System.Collections;
using System.Web;
using System.Web.Configuration;
using System.Web.UI;
using System.Web.UI.WebControls;


public partial class AdRotatorPage : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LoadDataFromDatabase(this.AdRotator1);
            LoadDataFromDatabase(this.AdRotator2,
            "ImageUrl", "NavigateUrl",
             "AlternateText");
            LoadDataFromXml(this.AdRotator3);
        }
    }
    void LoadDataFromDatabase(AdRotator adRotator)
    {
        string connectionString =
                WebConfigurationManager.ConnectionStrings[
                "RCVDB2000"].ConnectionString;

        ControlHelper cls = new
        ControlHelper(connectionString);
        cls.CommandText = 
        "select * from tblAdv";
        cls.CommandType = CommandType.Text;
        cls.InitProperties();
        cls.FillDataTableToAdRotator(
        adRotator);
        cls.Finalize();
    }
    void LoadDataFromDatabase(AdRotator adRotator,
    string imageUrlField,
    string navigateUrlField, 
    string alternateTextField)
    {
        string connectionString =
                WebConfigurationManager.ConnectionStrings[
                "RCVDB2000"].ConnectionString;

        ControlHelper cls = new
        ControlHelper(connectionString);
        cls.CommandText = 
        "select * from tblAdv";
        cls.CommandType = CommandType.Text;
        cls.InitProperties();
        cls.FillDataTableToAdRotator(
        adRotator, imageUrlField,
        navigateUrlField,alternateTextField);
        cls.Finalize();
    }
    void LoadDataFromXml(AdRotator adRotator)
    {         
        ControlHelper cls = new
        ControlHelper();
        cls.FillXmlToAdRotator(
        adRotator, "~/advs/advert.xml");
       
    }
}
